<template>
  <base-breadcrumb>
    <div class="page-detail">
      <searchData
        :search-data="searchArr"
        @search="search"
      />
      <a-card :bordered="false">
        <list-table
          ref="table"
          :columns="columns"
          :request="loadData"
          row-key="id"
        >
          <template
            slot="auditStatusStr"
            slot-scope="text, record, index"
          >
            <list-status
              :status="record.auditStatus"
              :text="text"
            />
          </template>
          <div
            slot="operation"
            slot-scope="text, record, index"
            class="pub-table-list-action"
          >
            <span @click="handleEdit(record, 3)">查看</span>
          </div>
        </list-table>
      </a-card>
    </div>
  </base-breadcrumb>
</template>
<script>
import {
    goodsDirectoryList,
    selectOption,
    goodsImport,
    directoryEdit,
    deleteByMainCatalog, goodsSearchList, findCatalogList
} from '@/api/material/goods/goods'
import totalPackageContractApi from '@/api/legal/branchContract/totalPackageContract'

export default {
	name:'a'+Date.now(),
    data() {
        return {
            searchArr: [
                {
                    name: '物资目录名称',
                    value: 'mateClassName',
                    type: 'input'
                },
                {
                    name: '状态',
                    value: 'commonStatus',
                    type: 'select',
                    data: [
                        { label: '无效', value: '0' },
                        { label: '有效', value: 1 },
                        { label: '已删除', value: -999 }
                    ]
                },
                {
                    name: '物资目录编码',
                    value: 'mateClassCode',
                    type: 'input'
                },

                {
                    name: '上级物资目录名称',
                    value: 'mateClassParentName',
                    type: 'input'
                },
                {
                    name: '上级物资目录编码',
                    value: 'mateClassParentCode',
                    type: 'input'
                }

            ],
            columns: [
                {
                    title: '物资目录名称',
                    dataIndex: 'mateClassName'
                },
                {
                    title: '物资目录编码',
                    dataIndex: 'mateClassCode'
                },
                {
                    title: '上级目录名称',
                    dataIndex: 'parentCatalogName'
                },
                {
                    title: '上级目录编码',
                    dataIndex: 'parentCatalogCode'
                },
                {
                    title: '状态',
                    dataIndex: 'commonStatusStr'
                },
                {
                    title: '操作',
                    dataIndex: 'operation',
                    scopedSlots: { customRender: 'operation' }
                }

            ],
            queryParam: {},
            loadData: params => findCatalogList(Object.assign(params, this.queryParam))
        }
    },
    methods: {
        search(val) {
            this.queryParam = val
            this.$refs.table.getData(null, true)
        },
        handleEdit(record, state) {
            this.$router.push({
                path: '/material/goods/directory/edit',
                query: {
                    row: record,
                    state: state
                }
            })
        }
    }
}
</script>
